package cn.bdqn.repository;

import cn.bdqn.pojo.AttriSetting;
import cn.bdqn.vo.AttrAndSetting;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface Asecu_AttrSettingRepository extends JpaRepository<AttriSetting,Integer> {

    @Query("SELECT new cn.bdqn.vo.AttrAndSetting(a2,a1) FROM Attributes a1,AttriSetting a2 WHERE a1.attrId = a2.id and a1.attrId=:attrId")
    List<AttrAndSetting> findAttrAndSetting(@Param("attrId") Integer attrId);

    @Query("SELECT new cn.bdqn.vo.AttrAndSetting(a2,a1) FROM Attributes a1,AttriSetting a2 WHERE a1.attrId = a2.id and a1.id=:id")
    AttrAndSetting findAttrAndSetting1(@Param("id") Integer id);

    @Modifying
    @Query("UPDATE AttriSetting SET mselect = :mselect WHERE id = :id")
    int edit(@Param("mselect") String mselect,@Param("id") int id);
}
